SRC_DIR = src
BIN_DIR = bin
build_all ?= no

build_file ?= src/teat1.cpp
ifeq ($(build_all), no)
	SOURCES = $(build_file)
	EXECUTABLES = $(BIN_DIR)/$(basename $(notdir $(build_file))) 
else
	SOURCES = $(wildcard $(SRC_DIR)/*.cpp)
	EXECUTABLES = $(patsubst $(SRC_DIR)/%.cpp, $(BIN_DIR)/%, $(SOURCES))
endif

# CC = icpc
CC = g++
CFLAGS = -std=gnu++0x -Wall
LDFLAGS = -lm

CFLAGS += -I$(MKL)/include
LDFLAGS += -L$(MKL)/lib -lmkl_intel_lp64 -lmkl_sequential -lmkl_core

all: $(EXECUTABLES)

$(BIN_DIR)/%: $(SOURCES) | $(BIN_DIR)
		$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)

# 创建bin目标
$(BIN_DIR):
		mkdir -p $(BIN_DIR)

clean:
		@echo "start clean executable file"
		rm -rf $(BIN_DIR)/*

.PHONY: all clean